const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')

const webpack = require('webpack')

module.exports = {
    mode: 'none',
    entry: './src/main.js',
    output: {
        publicPath: '/',
        filename: '[name].bundle.js',
        path: path.join(__dirname, 'dist')
    },

    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                    loaders: {
                        css: 'vue-style-loader!css-loader',
                        less: 'vue-style-loader!css-loader!less-loader'
                    }
                }
            },
            {
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                },
                exclude: /node_modules/
            },
            {
                test: /\.html$/,
                use: {
                    loader: 'html-loader',
                    options: {
                        attributes: {
                            list: [
                                {
                                    tag: 'img',
                                    attribute: 'src',
                                    type: 'src',
                                  },
                                  {
                                    tag: 'a',
                                    attribute: 'href',
                                    type: 'src',
                                  }
                            ]
                        }
                    }
                }
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.less$/,
                use: ['style-loader', 'css-loader', 'less-loader']
            },
            {
                test: /\.(jpg|png)$/,
                use: [{
                    loader: 'url-loader?limit=1024',
                    options: {
                        esModule: false
                    }
                }]                    
            }
        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        
        new webpack.DefinePlugin({
            BASE_URL: JSON.stringify('http://localhost:8088/')
        })
    ]
}